﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSVL02 
    {  
        public TSVL02()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VVERSART();
            this.DataContext = MV; 
            InitializeComponent();
         }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwVL = dwMaster;
            if (dwMaster != null)
            {
                KEY = dwMaster["VSPED"].ToString();
            }
            else
            {
                KEY = "";
            }
        } 
       
        public override void OnSARTChg(string value) 
        {
            TBMain.Clear();
            if (SART.Length == 0)
                return;
            dwData = TBMain.NewRow();
            dwData["VVERSART"] = value;
            SResult = TMV.QVER_1(dwData);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                row["KEY"] = Helpers.Helper.GetGB2312Value(row["VBEZ"].ToString()).Trim();
            }
            MergeData(SResult,false); 
        }
        public override void LOADBYAUF()
        {
            Locate("VSPED", ORDERNUM);
            base.LOADBYAUF();
        } 
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnSARTChg(SART);
            }
            else
            {
                VICC_WFEVENTS.SVWF.VL02(this.RUNID);
            }
            base.ManageCommand(sender, e);
        }
    }
}
